#include "comm.h"
#include "Fifo.h"
using namespace std;


int main()
{
    
    //获取key
    key_t key = GetshmkeyorDie();
    cout<<"key: "<<key<<endl;

    //获取共享内存
    int shmid = Getshm(key,desize);
    cout<<"shmid: "<<shmid<<endl;

    //将客户端进程与共享内存挂接
    char* addr = (char*)AddshmTouch(shmid);
    cout<<"AddshmTouch Success "<<endl;
    

    memset(addr, 0, desize);
    //可以协同
    Sync syn;
    syn.OpenWriteorDie();


    //进行通信
    // for(char c = 'a';c<='z';c++)
    // {
    //     addr[c-'a'] = c;
    //     sleep(1);
    //     syn.Wakeup();
    // }

    char ch[1024] = "i am process A";
    snprintf(addr,sizeof(ch),"%s",ch);
    sleep(1);
    syn.Wakeup();

    //去关联
    sleep(2);
    DeshmTouch(addr);


}